﻿using System;
using System.Threading;

namespace TimerTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ThreadPool.SetMaxThreads(1000, 1000);

            TimerCallback callback = new TimerCallback(ThreadPoolMessage);
            Timer t = new Timer(callback, "Hello Felix!", 0, 1000);
            Console.ReadKey();
        }

        static void ThreadPoolMessage(object data)
        {
            int a, b;
            ThreadPool.GetAvailableThreads(out a, out b);
            string message = string.Format("{0}\n CurrentThreadIs is:{1}\n" +
                " CurrentThread IsBackground:{2}\n" +
                " WorkerThread is:{3}\n CompletionPortThreads is:{4}\n",
                data + "Time now is " + DateTime.Now.ToLongTimeString(),
                Thread.CurrentThread.ManagedThreadId,
                Thread.CurrentThread.IsBackground.ToString(),
                a.ToString(), b.ToString());
            Console.WriteLine(message);
        }
    }
}
